const path = require("path")
const resolve = (dir) => path.resolve(__dirname, dir)
const CracoLessPlugin = require("craco-less")
// 导入less全局变量
const lessVars = require(resolve("src/styles/less/variables"))
// const { loaderByName, addAfterLoader } = require("@craco/craco")
// 该配置会和webpack配置整合
module.exports = {
	plugins: [
		{
			plugin: CracoLessPlugin,
			options: {
				lessLoaderOptions: {
					lessOptions: {
						modifyVars: lessVars,
						javascriptEnabled: true,
					},
				},
			},
		},
	],
	webpack: {
		alias: {
			"@": resolve("src"),
			"@img": resolve("src/assets/img"),
		},
		configure: (webapckConfig) => {
			/* addAfterLoader(webapckConfig, loaderByName("sass-loader"), {
				// 配置sass全局变量，如果配置完使用全局变量报错，说明包没下好
				loader: require.resolve("sass-resources-loader"),
				options: {
					resources: [resolve("src/styles/sass/variables.scss")],
				},
			}) */
			return webapckConfig
		},
	},
}
